<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<%Call CheckAdmin2()%>

<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="header">
<!--#include file="menu.asp"-->
</div>
<div class="main">
			<%
			if Session(ULVL)>0 then
				Showerror("权限不足")
				response.end
			end if

				Select Case request("action")
					Case "addclass"
						Call SQLClass("add",0)
					Case "editclass"
						Call SQLClass("edit",request.form("id"))
					Case "delclass"
						Call SQLClass("del",request("id"))
				end Select

				Select Case Request("Action")
					Case "edit"
						Call guild_edit_sql()
					Case else
						Call guild_edit()
						Call RaidClassList()
				End Select

			%>
  </div>
<div id="footer"><!--#include file="footer.asp"--></div>
</body>
</html>
<%
SUB guild_edit()
	Dim Arrpara
	sql="select top 1 * from guild"
	rs.open sql,conn,1,1
	if rs.bof or rs.eof then
		Response.write "<h4>内部错误 C000010</h4>"
	else
		Arrpara=split(rs("guild_para"),"|")
		Response.write "<form action='?action=edit' method='post'>"
		Response.write "<table class='outframe interlace'>"
		Response.write "<tr><th colspan='2'>公会信息</th></tr>"
		Response.write "<tr><td>公会名</td><td><input type='input' name='guild_name' value='"&rs("guild_name")&"' size='40'/></td></tr>"
		Response.write "<tr><td>副标题</td><td><input type='input' name='guild_sname' value='"&rs("guild_sname")&"' size='35'/></td></tr>"
		Response.write "<tr><td>所在服务器</td><td><input type='input' name='guild_server' value='"&rs("guild_server")&"'/> 填入所在服务器名字方能实时反应角色信息</td></tr>"
'		Response.write "<tr><td>规模</td><td><input type='input' name='guild_playernum' value='"&rs("guild_playernum")&"'/></td></tr>"
'		Response.write "<tr><td>老大</td><td><input type='input' name='guild_master' value='"&rs("guild_master")&"'/></td></tr>"
'		Response.write "<tr><td>官员</td><td><input type='input' size='50' name='guild_supervisor' value='"&rs("guild_supervisor")&"'/></td></tr>"
		Response.write "<tr><td>创立时间</td><td><input type='input' name='guild_createtime' value='"&rs("guild_createtime")&"'/></td></tr>"
		Response.write "<tr><td>团队活动次数</td><td><input type='input' name='guild_raidnum' value='"&rs("guild_raidnum")&"'/></td></tr>"
'		Response.write "<tr><td>目前计划</td><td><input type='input' name='guild_raidplan' value='"&rs("guild_raidplan")&"'/></td></tr>"
'		Response.write "<tr><td>公会规章</td><td><textarea name='guild_rules' rows='8' cols='50'>"&rs("guild_rules")&"</textarea></td></tr>"
'		Response.write "<tr><td>DKP制度</td><td><textarea name='guild_DKPrules' rows='8' cols='50'>"&rs("guile_DKPrules")&"</textarea></td></tr>"
		Response.write "<tr><td>界面主题</td><td><select name='guild_style'><option value='style' selected>默认主题</option><option value='style'>无</option></select></td></tr>"

		Response.write "<tr><td>图标URL</td><td><input type='input' name='guild_para01' value='"&Arrpara(1)&"' size='55'/></td></tr>"
		Response.write "<tr><td>格式后缀</td><td><input type='input' name='guild_para02' value='"&Arrpara(2)&"' size='5'/> 默认:.png</td></tr>"
		Response.write "<tr><td>精度</td><td><select name='guild_para03'><option value='0' "&LogicM(Arrpara(3),"0|1","Selected|","|")&">整数</option><option value='1' "&LogicM(Arrpara(3),"0|1","|Selected","|")&">保留两位小数</option></select></td></tr>"
		Response.write "<tr><td>留言</td><td><select name='guild_para04'><option value='1' "&LogicM(Arrpara(4),"0|1|2|3","|Selected||","|")&">允许留言</option><option value='2' "&LogicM(Arrpara(4),"0|1|2|3","||Selected|","|")&">允许在活动安排中留言</option><option value='3' "&LogicM(Arrpara(4),"0|1|2|3","|||Selected","|")&">允许在活动报告中留言</option><option value='0' "&LogicM(Arrpara(4),"0|1|2|3","Selected|||","|")&">关闭留言功能</option></select></td></tr>"
		Response.write "<tr><td></td><td><b>其余设置参数请用记事本打开config.asp进行修改</b></td></tr>"
		Response.write "<tr><td></td><td><input type='submit' value='确定'/></td></tr>"
		Response.write "</table>"
		Response.write "</form>"
	end if
	rs.close
END SUB

sub guild_edit_sql()
	'添加新的分类
	'验证提交数据有效性
	'数据库字段:
	Dim errorinfo
	if request("guild_name")="" then errorinfo=errorinfo & "<li>公会名请不要留空.</li>"
	if request("guild_sname")="" then errorinfo=errorinfo & "<li>副标题请不要留空.</li>"
	if not IsDate(request("guild_createtime")) then errorinfo=errorinfo & "<li>创立时间的格式不正确.</li>"
	if not IsNumeric(request("guild_raidnum")) then errorinfo=errorinfo & "<li>活动次数必须为数字.</li>"
	'if IsValidEmail(request("L_AuthorMail"))<>"true" and request("L_AuthorMail")<>"" then errorinfo=errorinfo & "<li>无效的邮箱地址.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
			sql="select top 1 * from guild"
			rs.open sql,conn,1,3
			if rs.bof or rs.eof then exit sub
			rs("guild_name")=request("guild_name")
			rs("guild_sname")=request("guild_sname")
			rs("guild_server")=request("guild_server")
'			rs("guild_playernum")=request("guild_playernum")
'			rs("guild_master")=request("guild_master")
'			rs("guild_supervisor")=request("guild_supervisor")
			rs("guild_createtime")=request("guild_createtime")
			rs("guild_raidnum")=request("guild_raidnum")
'			rs("guild_raidplan")=request("guild_raidplan")
			rs("guild_rules")=request("guild_rules")
			rs("guile_DKPrules")=request("guild_DKPrules")
			rs("guild_style")=request("guild_style")
			rs("guild_para")="|"&request("guild_para01")&"|"&request("guild_para02")&"|"&request("guild_para03")&"|"&request("guild_para04")&"|5|0|0|0|"
			rs.update
			rs.close

			Response.write "修改完成 <a href='"&Url&"'>继续修改</a> | <a href='/'>查看列表</a>"
	end if
end sub




Sub RaidClassList()
	Dim HtmlList
	HtmlList=HtmlList&"<table class='outframe interlace'>"
	HtmlList=HtmlList&"<tr><th colspan='4'>公会DKP分类设置 [<a href='admin_GuildInfo.asp'>添加新分类</a>]</th></tr>"
	HtmlList=HtmlList&"<tr class='coltitle'><td>ID</td><td>分类名(字符范围:A-Z,a-z,0-9)</td><td>描述</td><td>建议不要删除已有分类</td></tr>"
	SQL="select * from raid_class"
	rs.open sql,conn,1,1
		if not (rs.eof or rs.bof) then
			for i = 1 to rs.recordcount
				if Request("action")="editform" and Cint(Request("id"))=rs("id") then
					HtmlList=HtmlList&"<tr><form method='post' action='?action=editclass'><td><input type='hidden' name='id' value='"&rs("id")&"' />"&rs("id")&"</td><td><input type='text' name='class_name' value='"&rs("class_name")&"' /></td><td><input type='text' name='class_note' value='"&rs("class_note")&"' /></td><td><input type='submit' value='完 成' /></td></form></tr>"
				else
					HtmlList=HtmlList&"<tr><td>"&rs("id")&"</td><td>"&rs("class_name")&"</td><td>"&rs("class_note")&"</td><td><a href='?action=editform&amp;id="&rs("id")&"'>编辑</a> <a href='?action=delclass&amp;id="&rs("id")&"'>删除</a></td></tr>"
				end if
			rs.movenext
			next
		else
			HtmlList=HtmlList&"<tr><td colspan='4'>没有设置分类,系统正常运行至少需要一个DKP分类.</td></tr>"
		end if
	rs.close
	if Request("action")="" then HtmlList=HtmlList&"<tr><form method='post' action='?action=addclass'><td></td><td><input type='text' name='class_name' value='' /></td><td><input type='text' name='class_note' value='' /></td><td><input type='submit' value='添 加' /></td></form></tr>"
	HtmlList=HtmlList&"</table>"

	Response.write HtmlList
End Sub

Sub SQLClass(action,id)
	if not Isnumeric(id) then Exit Sub
	if action="del" then
		Conn.execute("Delete * from Raid_class where id="&id)
		Exit Sub
	end if
	'添加新的分类
	'验证提交数据有效性
	Dim errorinfo
	if request("class_name")="" then errorinfo=errorinfo & "<li>分类名请不要留空.</li>"
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<p>表单信息有误,提示如下:</p><ul>"&errorinfo&"</ul>"
		Response.write "请<a href='"&Url&"'>返回</a>重新修改."
	else
		'写入数据库
		if action="add" then
			Response.write "Done.3"
			sql="select top 1 * from raid_class"
			rs.open sql,conn,1,3
			rs.addnew
			rs("class_name")=request("class_name")
			rs("class_note")=request("class_note")
			rs.update
			rs.close
		elseif action="edit" then 
			Response.write "Done."
			sql="select top 1 * from raid_class where id="&id
			rs.open sql,conn,1,3
			if not (rs.bof or rs.eof) then 
				rs("class_name")=request("class_name")
				rs("class_note")=request("class_note")
				rs.update
				rs.close
			end if
		end if
	end if
End Sub

%>